home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / ranarg.zip / RANDARG.DOC < prev    next >
Text File  |  1987-03-15  |  3KB  |  88 lines

  1.         RANDARG.DOC           15 March 87                   Page 1
  2.  
  3.  
  4.         Copyright 1987  Michael M Rubenstein
  5.  
  6.         This software may be freely distributed provided no fee is
  7.         assessed.
  8.  
  9.  
  10.  
  11.         Description.
  12.  
  13.         RANDARG randomly selects an argument or a line from a file and
  14.         either executes it or echoes it to stdout.  It can be used to
  15.         randomly produce messages or commands in a batch file.
  16.  
  17.  
  18.  
  19.         Usage.
  20.  
  21.         To randomly select an argument, simply execute RANDARG with the
  22.         desired arguments.  Arguments containing spaces or tabs must be
  23.         enclosed in quotes or appostrophies.  For example, the command
  24.  
  25.              randarg "Syntax error -- reenter"  "You goofed"
  26.  
  27.         will write one of the two messages to stdout.
  28.  
  29.         If the -c option is given, the argument selected will be
  30.         executed.  For example, if you have a program TUNE which
  31.         generates one of 3 tunes depending on the argument, the command
  32.  
  33.              randarg -c "tune 1" "tune 2" "tune 3"
  34.  
  35.         will select the tune randomly.
  36.  
  37.         If the argument selected is empty, no operation is performed.
  38.  
  39.         Wild card expansion of file names may be used (though I haven't
  40.         found any real use for it).  Arguments included in quotes or
  41.         appostrophes are not expanded.
  42.  
  43.         If the -f option is given, selection is from a file rather than
  44.         from the command line.  The first line of the file must contain
  45.         the number of remaining lines in the file.  A random line after
  46.         line 1 is selected.  For example, the command
  47.  
  48.              randarg -f errmsg
  49.  
  50.         with the file ERRMSG containing
  51.  
  52.              2
  53.              Syntax error -- reenter
  54.              You goofed
  55.  
  56.         is equivalent to the first example.
  57.  
  58.         The -f option may be combined with -c.  The command
  59.         RANDARG.DOC           15 March 87                   Page 2
  60.  
  61.  
  62.  
  63.              randarg -fc tunecmd
  64.  
  65.         with the file TUNECMD containing
  66.  
  67.              3
  68.              tune 1
  69.              tune 2
  70.              tune 3
  71.  
  72.         is equivalent to the second example.
  73.  
  74.         The algorithm used is not suitable for very large files since it
  75.         reads the file sequentially to get the line selected.  If the
  76.         first line of the file does not contain the number of lines, the
  77.         number is 0, or if there are not enough lines in the file,
  78.         RANDARG exits without comment.
  79.  
  80.  
  81.  
  82.         For the Hacker.
  83.  
  84.         RANDARG is written in AZTEC C with a modified run time system.
  85.         The run time system handles expansion of wildcards and quoted
  86.         arguments.  The code is very standard and there should be little
  87.         difficulty in porting to other versions of C.
  88.